package edu.gdkm.dao;

import edu.gdkm.pojo.Resume;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * 简历数据访问接口
 */
public interface ResumeDao {
    
    /**
     * 插入简历
     */
    @Insert("INSERT INTO resume(user_id, resume_name, template_id, education_experience, work_experience, project_experience, skills, certificates, hobbies, language_ability, internship_experience, visibility, create_time, update_time) VALUES(#{userId}, #{resumeName}, #{templateId}, #{educationExperience}, #{workExperience}, #{projectExperience}, #{skills}, #{certificates}, #{hobbies}, #{languageAbility}, #{internshipExperience}, #{visibility}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Resume resume);
    
    /**
     * 根据ID删除简历
     */
    @Delete("DELETE FROM resume WHERE id = #{id}")
    int deleteById(Long id);
    
    /**
     * 更新简历信息
     */
    @Update("UPDATE resume SET user_id = #{userId}, resume_name = #{resumeName}, template_id = #{templateId}, education_experience = #{educationExperience}, work_experience = #{workExperience}, project_experience = #{projectExperience}, skills = #{skills}, certificates = #{certificates}, hobbies = #{hobbies}, language_ability = #{languageAbility}, internship_experience = #{internshipExperience}, visibility = #{visibility}, update_time = #{updateTime} WHERE id = #{id}")
    int update(Resume resume);
    
    /**
     * 根据ID查询简历
     */
    @Select("SELECT id, user_id, resume_name, template_id, education_experience, work_experience, project_experience, skills, certificates, hobbies, language_ability, internship_experience, visibility, create_time, update_time FROM resume WHERE id = #{id}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "resumeName", column = "resume_name"),
        @Result(property = "templateId", column = "template_id"),
        @Result(property = "educationExperience", column = "education_experience"),
        @Result(property = "workExperience", column = "work_experience"),
        @Result(property = "projectExperience", column = "project_experience"),
        @Result(property = "skills", column = "skills"),
        @Result(property = "certificates", column = "certificates"),
        @Result(property = "hobbies", column = "hobbies"),
        @Result(property = "languageAbility", column = "language_ability"),
        @Result(property = "internshipExperience", column = "internship_experience"),
        @Result(property = "visibility", column = "visibility"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    Resume selectById(Long id);
    
    /**
     * 查询所有简历
     */
    @Select("SELECT id, user_id, resume_name, template_id, education_experience, work_experience, project_experience, skills, certificates, hobbies, language_ability, internship_experience, visibility, create_time, update_time FROM resume")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "resumeName", column = "resume_name"),
        @Result(property = "templateId", column = "template_id"),
        @Result(property = "educationExperience", column = "education_experience"),
        @Result(property = "workExperience", column = "work_experience"),
        @Result(property = "projectExperience", column = "project_experience"),
        @Result(property = "skills", column = "skills"),
        @Result(property = "certificates", column = "certificates"),
        @Result(property = "hobbies", column = "hobbies"),
        @Result(property = "languageAbility", column = "language_ability"),
        @Result(property = "internshipExperience", column = "internship_experience"),
        @Result(property = "visibility", column = "visibility"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    List<Resume> selectAll();
    
    /**
     * 根据用户ID查询简历列表
     */
    @Select("SELECT id, user_id, resume_name, template_id, education_experience, work_experience, project_experience, skills, certificates, hobbies, language_ability, internship_experience, visibility, create_time, update_time FROM resume WHERE user_id = #{userId}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "resumeName", column = "resume_name"),
        @Result(property = "templateId", column = "template_id"),
        @Result(property = "educationExperience", column = "education_experience"),
        @Result(property = "workExperience", column = "work_experience"),
        @Result(property = "projectExperience", column = "project_experience"),
        @Result(property = "skills", column = "skills"),
        @Result(property = "certificates", column = "certificates"),
        @Result(property = "hobbies", column = "hobbies"),
        @Result(property = "languageAbility", column = "language_ability"),
        @Result(property = "internshipExperience", column = "internship_experience"),
        @Result(property = "visibility", column = "visibility"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    List<Resume> selectByUserId(Long userId);
}
